<?php

declare(strict_types=1);

namespace app\common\model;


class ExamineBank extends Base
{

    protected $name = 'examine_bank';
    /**
     * 添加考生试卷
     */
    public static function addBank($param,$user)
    {
        try {
            $list = PaperBank::where(['paper_id'=>$param['paper_id']])->select();
            foreach($list as $k=>$v){
                $info = parent::where(['examine_id'=>$param['id'],'uid'=>$user->id,'exam_id'=>$v['exam_id']])->find();
                $data = [
                    'examine_id'=>$param['id'],
                    'uid'=>$user->id,
                    'exam_id'=>$v['exam_id'],
                    'types'=>$v['types']
                ];
                if(empty($info)){
                    parent::create($data);
                }
            }
            return ['code'=>1,'msg'=>'添加成功'];
        }catch (\Exception $e){
            return ['code'=>-1,'msg'=>$e->getMessage()];
        }   
    }
}
